package edu.udlap.spring2008.is300.finalexam.framework.mvc.model.database.filters;

import java.util.ArrayList;

/**
 *
 * @author Ruslán Ledesma Garza
 */
public abstract class ImageRecordFilter
{
    protected boolean isNegated_;
    protected Object filterValue_;
    
    /**
     * Constructs an sql constraint to be used in a where clause.
     * @return the constraint.
     */
    public abstract String getSqlConstraints();
    
    /**
     * Constructs an array list with all the concrete filters involved in
     * the construction of the sql constraint.
     * @return
     */
    public abstract ArrayList<ImageRecordFilter> getAppliedImageRecordFilters();
    
    /**
     * Tells if the concrete image record filter is negated.
     * @return
     */
    public boolean isNegated()
    {
        return isNegated_;
    }
    
    /**
     * Returns an object related to the concrete image record filter, which
     * represents part of its semantic.
     * @return
     */
    public Object getFilterValue()
    {
        return filterValue_;
    }
    
    @Override
    public int hashCode() {
        int hash = 3;
        return hash + getSqlConstraints().hashCode();
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        /*if (getClass() != obj.getClass()) {
            return false;
        }*/
        final ImageRecordFilter other = (ImageRecordFilter) obj;
        
        if(!this.getSqlConstraints().
                equals(other.getSqlConstraints()))
            return false;
        
        return true;
    }
}
